<?php
echo '<ul class="right_botron">';
if ($idUser){
	echo '<li><a class="lesons" href="' . W_ABSPATH . 'tutorial/lesson/add' . (isset($idFolder) ? ('?idFolder=' . $idFolder . (isset($idTutorial) ? ('&idTutorial=' . $idTutorial . (isset($idTheme) ? ('&idTheme=' . $idTheme) : NULL)) : NULL)) : NULL) . '">Добавить урок</a></li>';
}
if ($idUser && isset($idFolder) && $idFolder != NULL && isset($idTutorial) && $idTutorial != NULL && isset($idTheme) && $idTheme != NULL && isset($idLesson) && $idLesson != NULL
  && isset($arrLesson) && ($idUser == $arrLesson['ID_user'] || User_User::checkIfUser('admin'))){
	echo '<li><a class="edit_lesson" href="' . W_ABSPATH . 'tutorial/' . $tutorialNameForLink . '/lesson/' . $idLesson . '/edit">Редактировать урок</a></li>';
  echo '<li><a class="delete_lesson js_button" href="" onClick="tutorial.deleteLesson(this, ' . $idLesson . '); return false;"><span>Удалить урок</span></a></li>';
}
if ($idUser && isset($idFolder) && $idFolder != NULL && isset($idTutorial) && $idTutorial != NULL && isset($idTheme) && $idTheme != NULL  && $userRole && $userRole == 2){
	echo '<li><a class="edit_theme js_button" id="editThemeNameLink" href=""><span>Изменить название темы</span></a></li>';
  echo '
		<form id="editThemeName" style="display:none;" action="" method="post" onsubmit="tutorial.sendNewThemeName(this); return false;">
			<br />
			<div class="box_trext_form">
				<label>Название темы: </label>
				<div class="info_label">
					<textarea cols="22" rows="3" name="themeName" style="width: 185px;">'.$themeName.'</textarea>
				</div>
			</div>

			<input type="hidden" name="idTheme" value=' . $idTheme . ' />

			<div class="box_trext_form">
				<label></label>
				<div class="info_label">
					<input class="main_btn" name="submitNewThemeName" type="image" src="' . W_IMAGES . 'button/btn_main_otpravit.gif" />
				</div>
			</div>
		</form>';
}
if ($idUser && isset($idFolder) && $idFolder != NULL && isset($idTutorial) && $idTutorial != NULL){
  echo '<li><a href="/" id="tutorialThemeOfferLink" name="tutorialThemeOfferLink" class="tema js_button" ><span>Предложить тему</span></a>
		<form id="tutorialThemeOffer" style="display:none;" action="" method="post" onsubmit="tutorial.sendThemeOffer(this); return false;">
			<br />
			<div class="box_trext_form">
				<label style="width: 270px;">Предлагаемая тема: </label>
				<div class="info_label">
					<textarea cols="22" rows="3" name="newThemeOfferName" style="width: 270px;"></textarea>
				</div>
			</div>

			<input type="hidden" name="idTutorial" value=' . $idTutorial . ' />

			<div class="box_trext_form">
				<label></label>
				<div class="info_label" style="float:right;">
					<input class="main_btn" name="submitNewThemeOffer" style="margin-top:10px;margin-bottom:5px;" type="image" value="Заявка на добавление" src="' . W_IMAGES . 'button/btn_main_otpravit.gif" />
				</div>
			</div>
			<div class="clear"></div>
		</form>
	</li>';
}
  
if (isset($idTutorial) && $idUser && $userRole && $userRole == 2)
		echo '<li><a href="' . W_ABSPATH . 'tutorial/' . $tutorialNameForLink . '/theme/offers">Предложения тем</a></li>';
if (isset($idTutorial)){
		include(BLOCKS . 'tutorial/themePriority.php');
	}
echo '</ul>';
  // если это страница урока
if (isset($idLesson) && $idLesson != NULL){
	View_Tutorial::viewComplexMenu(array('url_name'=>$tutorialNameForLink), null, $curUrl, $idComplex, $idLesson, $arrThemeForMenu, $idTheme, $idFolder, $idTutorial );
	View_Tutorial::showAnotherAuthorsInThemeList($arrAnotherAuthors, $objTutorial);
}

require_once(TEMPLATE . 'columns/banner.php');
if (isset($idTutorial))
	include(BLOCKS . 'tutorial/themeOfferView.php');

if(isset($idFolder) && $idFolder != NULL && isset($idTutorial) && $idTutorial != NULL && isset($idLesson) && $idLesson != NULL){
// урок самоучителя
echo '
	<h3>Параметры урока</h3>
	<div class="stats">
		<ul>
			<li class="complexityForLesson">Сложность темы: <strong>' . round($arrLesson['theme_average_complexity_mark'], 2) . '</strong></li>
			<li class="complexityForLesson">Сложность комплекса: <strong>' . round($arrLesson['complex_average_complexity_mark'], 2) . '</strong></li>
			<li class="raitingForLesson">Рейтинг комплекса: <strong>' . round($arrLesson['complex_average_mark'], 2) . '</strong></li>
		</ul>
	</div>';

View_Statistics::rightBlock($arrLesson); // статистика

}

$arrSortMark = Tutorial::getSortMarkDay(5);
$arrSortMarkSize = sizeof($arrSortMark);
if ($arrSortMarkSize != 0){
	echo '<h2>Лучшие уроки за сутки</h2>';
	for ($num = 0; $num < 5 AND $num < $arrSortMarkSize; $num++){
		echo '
		<div class="news">
			<ul>
				<li><a href="' . W_ABSPATH . 'tutorials?idFolder=' . $arrSortMark[$num]['ID_folder'] . '&pageNum=1">' . $arrSortMark[$num]['folder_name'] . '</a></li>
				<li><a href="' . W_ABSPATH . 'tutorial/' . $arrSortMark[$num]['url_name'] . '">' . $arrSortMark[$num]['tutorial_name'] . '</a></li>
				<li><a href="' . W_ABSPATH . 'tutorial/' . $arrSortMark[$num]['url_name'] . '/theme/' . $arrSortMark[$num]['ID_tutorial_theme'] . '/1">' . $arrSortMark[$num]['theme_name'] . '</a></li>
				<li class="last"><a href="' . W_ABSPATH . 'tutorial/' . $arrSortMark[$num]['url_name'] . '/lesson/' . $arrSortMark[$num]['ID_tutorial_lesson'] . '">' . (strlen($arrSortMark[$num]['lesson_name']) > 25 ? Service_String::cutString($arrSortMark[$num]['lesson_name'], 25) : $arrSortMark[$num]['lesson_name']) . '
				</a></li>
			</ul>
			<span class="right_news">' . round($arrSortMark[$num]['average_mark'], 2) . '</span>
		</div>';
	}
}
?>